home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / CHSTWO.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  572b  |  22 lines

  1. PROCEDURE chstwo(bins1,bins2: barray; nbins,knstrn: integer;
  2.        VAR df,chsq,prob: real);
  3. (* Programs using routine CHSTWO must define type
  4. TYPE
  5.    barray = ARRAY [1..nbins] OF real;
  6. in the main routine.   *)
  7. VAR
  8.    j: integer;
  9. BEGIN
  10.    df := nbins-1-knstrn;
  11.    chsq := 0.0;
  12.    FOR j := 1 TO nbins DO BEGIN
  13.       IF ((bins1[j] = 0.0) AND (bins2[j] = 0.0)) THEN BEGIN
  14.          df := df-1.0
  15.       END ELSE BEGIN
  16.          chsq := chsq+sqr(bins1[j]-bins2[j])/
  17.                (bins1[j]+bins2[j])
  18.       END
  19.    END;
  20.    prob := gammq(0.5*df,0.5*chsq)
  21. END;
  22.